pub mod backtest;
pub mod db;
pub mod model;

pub fn round2(f: f64) -> f64 {
    let result = (f * 100.0).round() / 100.0;
    if result.is_nan() || result.is_infinite() {
        0.0
    } else {
        result
    }
}

pub fn round4(f: f64) -> f64 {
    let result = (f * 10000.0).round() / 10000.0;
    if result.is_nan() || result.is_infinite() {
        0.0
    } else {
        result
    }
}

pub fn add(left: usize, right: usize) -> usize {
    left + right
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}
